package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.EmsPeakShiftDetail;
import com.econ.powercloud.ems.dal.mapper.EmsPeakShiftDetailMapper;
import com.mysql.cj.util.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zjr
 * @create 2021/7/22 下午2:33
 * @description
 */
@Repository
public class EmsPeakShiftDetailDAO extends ServiceImpl<EmsPeakShiftDetailMapper, EmsPeakShiftDetail> {
    public void addPeakShiftDetailList(List<EmsPeakShiftDetail> emsPeakShiftDetails) {
        this.baseMapper.insertBatch(emsPeakShiftDetails);
    }

    public void removeByPeakShiftId(String peakShiftId) {
        LambdaQueryWrapper<EmsPeakShiftDetail> emsPeakShiftDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
        emsPeakShiftDetailLambdaQueryWrapper.eq(!StringUtils.isNullOrEmpty(peakShiftId), EmsPeakShiftDetail::getPeakShiftId, peakShiftId);
        this.baseMapper.delete(emsPeakShiftDetailLambdaQueryWrapper);
    }

    public List<EmsPeakShiftDetail> getListByPeakShiftId(String peakShiftId) {
        LambdaQueryWrapper<EmsPeakShiftDetail> emsPeakShiftDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
        emsPeakShiftDetailLambdaQueryWrapper.eq(!StringUtils.isNullOrEmpty(peakShiftId), EmsPeakShiftDetail::getPeakShiftId, peakShiftId);
        return this.baseMapper.selectList(emsPeakShiftDetailLambdaQueryWrapper);
    }
}
